using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using deckAnalyser.Support;

namespace deckAnalyser.Controls
{
    public partial class CardViewControl : UserControl
    {
        public CardViewControl()
        {
            InitializeComponent();
        }

        private void UpdateData()
        {
            if (CardName != "")
            {
                String baseUrl = "http://www.wizards.com/global/images/magic/general/";

                string filename = (cardName + ".jpg").Replace(" ", "_").Replace("'", "").Replace("-", "_").Replace(",", "_").Replace(Char.ConvertFromUtf32(65533), "Ae").Replace("__", "_");
                filename = filename.Replace("(1)", "").Replace("(2)", "").Replace("(3)", "");
                filename = filename.Replace(":", "");


                if (ImageCache.IsOpen)
                    pictureBox.LoadAsync(ImageCache.Get(filename, baseUrl + filename));
            }
        }

        private String cardName = "";
        public String CardName
        {
            get { return cardName; }
            set { cardName = value; UpdateData(); }
        }

    }
}
